home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.3 KB | 51 lines | [TEXT/ttxt] |
- --<<<
- -- Kaleida Labs, Inc.
- -- Field Guide to the ScriptX Language
- -- chapter 6, example 11
-
- -- specializing getters and setters for inherited variables
-
- -- VerbosePresenter example
- class VerbosePresenter (TwoDPresenter)
- instance variables
- _x, _y
- instance methods
- method xSetter self value -> (
- self._x := value
- local val
- format debug "x is stored internally as %* " value @normal
- format debug "but displayed as %*\n" (val := round value) @normal
- nextMethod self val
- )
- method ySetter self value -> (
- self._y := value
- local val
- format debug "y is stored internally as %* " value @normal
- format debug "but displayed as %*\n" (val := round value) @normal
- nextMethod self val
- )
- end
-
- method xGetter self {class VerbosePresenter} -> (
- local value := nextMethod self
- format debug "x is displayed as %* " value @normal
- format debug "but stored internally as %*\n" self._x @normal
- return value
- )
- method yGetter self {class VerbosePresenter} -> (
- local value := nextMethod self
- format debug "y is displayed as %* " value @normal
- format debug "but stored internally as %*\n" self._y @normal
- return value
- )
-
- -- create an instance of VerbosePresenter and assign values to x and y
- -- to test our new setter methods
- global vp := new VerbosePresenter
- vp.x := 3.33
- vp.y := 6.66
-
- -- now test the new getter methods
- vp.x
- vp.y
- -->>>